import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'

export default defineConfig({
  //跨域代理(可开启多个)
  plugins: [vue()],
  resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
  server: {
    port: 3001,
    proxy: {
      '/api': {
        target: 'http://localhost:3000/',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    },
    open: true              //项目启动时是否打开浏览器
    // host: 'localhost',   // 开放服务器启动的地址，默认时localhost
    // ws:true,             //开启websockets代理
    // secure:false         //验证SSL证书
  }
})
